home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
flxkey.exe
/
FLXKEY.DOC
< prev
next >
Wrap
Text File
|
1993-02-21
|
31KB
|
933 lines
FlxKey 1.1 : Registration-key Unit
for Borland's Turbo Pascal 4.0 - 7.0
Copyright (c) 1993, Guy McLoughlin
All rights reserved.
Released as Shareware, 22/02/93.
DESCRIPTION
===========
FlxKey is an easy to use Turbo Pascal unit, that enables
you to create encrypted user-registration keys for your
programs.
To make the whole process as "painless" as possible,
FlxKey performs all the encryption, decryption, and error-
checking for you.
The FlxKey unit comes pre-compiled in six .TPU files:
FLX40TPU.ZIP (Turbo Pascal 4.0)
FLX50TPU.ZIP (Turbo Pascal 5.0)
FLX55TPU.ZIP (Turbo Pascal 5.5)
FLX60TPU.ZIP (Turbo Pascal 6.0)
FLX70TPU.ZIP (Turbo Pascal 7.0 "real mode" )
FLX70TPP.ZIP (Borland Pascal 7.0 "protected mode")
Also included are several sample programs, each demonstrat-
ing a different method of using the FlxKey unit.
PUTTING FLX TO WORK
===================
There are only two routines to call within the FlxKey unit:
CreateFlxKey - Creates an encrypted registration-key
based on the data you pass to it.
ReadFlxKey - Reads/decodes/error-checks an encrypted
registration-key, and returns the key's
data.
Both of these routines will return an error-code number,
which your program can use to determine it's best course of
action.
Page 1
CREATING A REGISTRATION-KEY
===========================
Before you can use the CreateFlxKey routine you must:
1- Place the name of the FlxKey unit in your program's
"uses" declaration.
ie: uses
Crt,
FlxKey;
2- Declare a "rc_Flx" variable, used to pass the data you
want to encrypt into the registration key.
(* FlxKey type definitions. *)
type
st_20 = string[20];
st_30 = string[30];
st_254 = string[254];
rc_Flx = record
FirstName : st_20;
LastName : st_30;
Address1 : st_30;
Address2 : st_30;
Address3 : st_30;
AppName : st_20;
Version : word;
Serial : longint;
Date : longint;
Access : word;
MiscData : st_254
end;
var
TempKeyRec : rc_Flx;
3- Declare two encryption-code string variables, to be
used to encrypt the registration key. These strings
can be from 1 character to 100 characters in length,
though I would recommend using at least 10 characters
for each encryption string.
ie: var
Ecode1,
Ecode2 : string[100];
or
var
Ecode1,
Ecode2 : st_100;
Page 2
4- Declare a word-type variable to hold the error-code
returned by CreateFlxKey.
ie: var
ErrorCode : word;
5- Declare a path/filename string variable, that will be
used to pass the name of the encrypted registration-
key file you want to create.
ie: var
RegKeyName : string[79];
or
var
RegKeyName : st_79;
6- Assign your data to the "rc_Flx" variable.
To assign data to the "TempKeyRec" you declared earlier,
you could code something like this:
(* TempKeyRec is our "rc_Flx" type variable. *)
with TempKeyRec do
begin
(* Assign the firstname, lastname, and address of the *)
(* user this key is being created for. *)
FirstName := 'John';
LastName := 'Smith';
Address1 := '1234 AnyPlace Road,';
Address2 := 'BigCity, BigPlace,';
Address3 := 'BigCountry, BigZip';
(* Assign the name of your amazing program that this *)
(* key belongs to. *)
AppName := 'Amazing Program';
(* Assign the version number of your program. For *)
(* example, the number below could be used to represent *)
(* version 3.10 of your software. *)
Version := 310;
(* Assign the serial number of the registration-key you *)
(* are creating for this user. *)
Serial := 1234567890;
(* This is the date that will be stored in the *)
(* encrypted registration-key, in standard Turbo Pascal *)
(* packed "datetime" format. If you set this variable *)
(* to zero, the CreateFlxKey routine will automatically *)
(* stamp it with the current date/time. *)
Date := 0;
Page 3
(* This is the user-access level that you are assigning *)
(* to this user. From 0 to 65,535. *)
Access := 1234;
(* This variable is used to store a miscellaneous data *)
(* string, which can be from 1..254 characters in long. *)
MiscData := 'You can place what ever sort of data' +
' you like' + #13#10 + ' ' +
' within this field, upto 254 ' +
'bytes worth.'
end;
7- Assign the path/filename to the encrypted registration-
key you want to create.
ie: RegKeyName := 'AMAZPROG.KEY';
or
RegKeyName := 'C:\AP-KEYS\AMAZPROG.KEY';
8- Assign data to the two the two encryption-code strings
that you want to use to encrypt the registration-key.
This is a very crucial step in the process, that will
be covered in more detail when we look at "embedding"
random encryption-codes into your programs.
For now we will assign two simple encryption-code
strings, to be used for demonstration purposes.
ie: Ecode1 := 'Apple';
Ecode2 := 'Orange';
Now that you've created all the variables necessary, and
assigned data to them, you can call "CreateFlxKey" to create
the encrypted registration key.
ie: CreateFlxKey(TempKeyRec, Ecode1, Ecode2,
RegKeyName, ErrorCode);
If this call was successful, the ErrorCode variable should
be equal to zero, and you should now find a new file on your
disk called "AMAZPROG.KEY".
CHECKING FOR ERRORS
===================
Ok, so what happens when the Er